package puzzle;

public class Block {

	/**
	 * width of the piece
	 */
	private int width;
	/**
	 * Height of the piece
	 */
	private int height;
	/**
	 * x position of the piece
	 */
	private int posx;
	/**
	 * y position of the piece
	 */
	private int posy;
	
	/**
	 * creates a piece with 4 parameters
	 * @param heigth the desired height of the piece
	 * @param width the desired width of the piece
	 * @param posx the desired x position of the piece
	 * @param posy the desired y position of the piece
	 */
	public Block(int height, int width, int posx, int posy) {
		super();
		this.width = width;
		this.height = height;
		this.posx = posx;
		this.posy = posy;
	}
	
	/**
	 * gives the piece's width
	 * @return piece's width
	 */
	public int getWidth() {
		return width;
	}

	/**
	 * Set the piece's width to the desired value
	 * @param width the desired width of the piece
	 */
	public void setWidth(int width) {
		this.width = width;
	}

	/**
	 * gives the piece's height
	 * @return piece's height
	 */
	public int getHeight() {
		return height;
	}

	/**
	 * Set the piece's width to the desired value
	 * @param width the desired width of the piece
	 */
	public void setHeight(int height) {
		this.height = height;
	}

	/**
	 * gives the piece's x position
	 * @return piece's x position
	 */
	public int getPosx() {
		return posx;
	}

	/**
	 * Set the piece's x position to the desired value
	 * @param width the desired x position of the piece
	 */
	public void setPosx(int posx) {
		this.posx = posx;
	}

	/**
	 * gives the piece's y position
	 * @return piece's y position
	 */
	public int getPosy() {
		return posy;
	}

	/**
	 * Set the piece's y position to the desired value
	 * @param width the desired y position of the piece
	 */
	public void setPosy(int posy) {
		this.posy = posy;
	}
	
	public Block clone(){
		Block b = new Block(height,width,posx,posy);
		return b;
	}
	
	public String toString(){
		return "heigth : "+height+" width : "+width+" posx : "+ posx+" posy : "+posy;
	}
	
	public boolean equals(Block b) {
	return (b.getPosx() == posx && b.getPosy() == posy &&  b.getWidth() == width && b.getHeight() == height);
	}
	
	public boolean symetric(Block b){
		return (b.getPosx() == posx && b.getPosy() == width-posy-b.width &&  b.getWidth() == width && b.getHeight() == height);
	}
}
